有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何将数据插入到content://media/external/audio/albumart通过内容解析器(如果是Mediastore)。音频媒体数据已弃用?

我正试图通过内容解析器将位图插入到content://media/external/audio/albumart。但运行后的数据不插入,并且不存在异常和错误。后来我观察到Mediastore。音频媒体安卓不推荐使用数据。告诉我怎么修。以下示例:

 private static void writeArtwork(Context context, Bitmap bmp, long albumId) {
    ContentResolver res = context.getContentResolver();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);
    byte[] bytes = baos.toByteArray();
    Log.i(TAG, "Bytes: " + bytes.length);
    ContentValues values = new ContentValues();
    values.put("album_id", albumId);
    values.put("_data", bytes);
    Uri uri = res.insert(Uri.parse("content://media/external/audio/albumart"), values);
    Log.d(TAG, String.valueOf(uri));
}

共 (0) 个答案